package com.ztman.router.common.dagger.module;

import com.ztman.router.common.base.MyApplication;
import com.ztman.router.common.core.DataManager;
import com.ztman.router.common.core.db.DbHelper;
import com.ztman.router.common.core.db.LitepalHelper;
import com.ztman.router.common.core.http.HttpHelper;
import com.ztman.router.common.core.http.RetrofitHelper;
import com.ztman.router.common.core.prefer.PreferenceHelper;
import com.ztman.router.common.core.prefer.PreferenceHelperImpl;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * @Title:AppModule
 * @Package:com.ztman.router.common.dagger.module
 * @Description:注入类中需要实例化的全局获取Context的Module类型
 * @Auther:YJH
 * @Email:yuannunhua@gmail.com
 * @Date:2018/5/1015:02
 */

@Module
public class AppModule {
    private MyApplication myApplication;

    public AppModule(MyApplication _myApplication){
        this.myApplication = _myApplication;
    }

    @Singleton
    @Provides
    MyApplication getContext(){
        return myApplication;
    }


    @Provides
    @Singleton
    HttpHelper provideHttpHelper(RetrofitHelper retrofitHelper) {
        return retrofitHelper;
    }

    @Provides
    @Singleton
    DbHelper provideDBHelper(LitepalHelper litepalHelper) {
        return litepalHelper;
    }

    @Provides
    @Singleton
    PreferenceHelper providePreferencesHelper(PreferenceHelperImpl implPreferencesHelper) {
        return implPreferencesHelper;
    }

    @Singleton
    @Provides
    DataManager provideDataManager(HttpHelper httpHelper, DbHelper dbhelper, PreferenceHelper preferencesHelper) {
        return new DataManager(httpHelper, dbhelper, preferencesHelper);
    }

}
